#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

struct Customer {
    int arrivedTime;
    int serviceTime;
};

struct Window {
    int id;
    int endTime;
    std::vector<Customer> customers;
};

bool WindowCompare(const Window& a, const Window& b) {
    if (a.endTime != b.endTime) {
        return a.endTime < b.endTime;
    }
    return a.id < b.id;
}

/**
 * 银行单队列多窗口模式
 */
int main() {
    std::queue<Customer> customers;
    std::vector<int> waitTimes;

    int N;
    std::cin >> N;

    for (int i = 0; i < N; i++) {
        int arrivedTime, serviceTime;
        std::cin >> arrivedTime >> serviceTime;
        customers.push({ arrivedTime, serviceTime });
    }

    int K;
    std::cin >> K;

    std::vector<Window> windows(K);
    for (int i = 0; i < K; i++) {
        windows[i].id = i + 1;
        windows[i].endTime = 0;
    }

    while (!customers.empty()) {
        Customer customer = customers.front();
        customers.pop();

        std::sort(windows.begin(), windows.end(), WindowCompare);
        Window& selectedWindow = windows[0];

        int waitTime = std::max(0, selectedWindow.endTime - customer.arrivedTime);
        waitTimes.push_back(waitTime);

        selectedWindow.endTime = std::max(selectedWindow.endTime, customer.arrivedTime) + customer.serviceTime;
        selectedWindow.customers.push_back(customer);
    }

    double meanWaitTime = 0.0;
    for (int wt : waitTimes) {
        meanWaitTime += wt;
    }
    meanWaitTime /= N;
    printf("%.1lf ", meanWaitTime);

    int maxWait = *std::max_element(waitTimes.begin(), waitTimes.end());
    std::cout << maxWait << " ";

    int maxEndTime = 0;
    for (const Window& w : windows) {
        if (w.endTime > maxEndTime) {
            maxEndTime = w.endTime;
        }
    }
    std::cout << maxEndTime;

    return 0;
}